<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="发送登记中心时间:YYYY-MM-DD HH:mm:ss" prop="sendtime">
      <el-input v-model="dataForm.sendtime" placeholder="发送登记中心时间:YYYY-MM-DD HH:mm:ss"></el-input>
    </el-form-item>
    <el-form-item label="接收登记中心时间:YYYY-MM-DD HH:mm:ss" prop="recvtime">
      <el-input v-model="dataForm.recvtime" placeholder="接收登记中心时间:YYYY-MM-DD HH:mm:ss"></el-input>
    </el-form-item>
    <el-form-item label="发起网点号" prop="obankid">
      <el-input v-model="dataForm.obankid" placeholder="发起网点号"></el-input>
    </el-form-item>
    <el-form-item label="业务标识码" prop="servicecode">
      <el-input v-model="dataForm.servicecode" placeholder="业务标识码"></el-input>
    </el-form-item>
    <el-form-item label="业务类型" prop="ywlx">
      <el-input v-model="dataForm.ywlx" placeholder="业务类型"></el-input>
    </el-form-item>
    <el-form-item label="登记事项" prop="djsx">
      <el-input v-model="dataForm.djsx" placeholder="登记事项"></el-input>
    </el-form-item>
    <el-form-item label="是否存在合同备案信息集:1-是;0-否" prop="ishtbaset">
      <el-input v-model="dataForm.ishtbaset" placeholder="是否存在合同备案信息集:1-是;0-否"></el-input>
    </el-form-item>
    <el-form-item label="区划代码" prop="region">
      <el-input v-model="dataForm.region" placeholder="区划代码"></el-input>
    </el-form-item>
    <el-form-item label="办理点" prop="bld">
      <el-input v-model="dataForm.bld" placeholder="办理点"></el-input>
    </el-form-item>
    <el-form-item label="并案标识码(合并编码)" prop="babsm">
      <el-input v-model="dataForm.babsm" placeholder="并案标识码(合并编码)"></el-input>
    </el-form-item>
    <el-form-item label="集体件标识码" prop="jtjbsm">
      <el-input v-model="dataForm.jtjbsm" placeholder="集体件标识码"></el-input>
    </el-form-item>
    <el-form-item label="登记原因" prop="djyy">
      <el-input v-model="dataForm.djyy" placeholder="登记原因"></el-input>
    </el-form-item>
    <el-form-item label="附记" prop="fj">
      <el-input v-model="dataForm.fj" placeholder="附记"></el-input>
    </el-form-item>
    <el-form-item label="领证人" prop="lzr">
      <el-input v-model="dataForm.lzr" placeholder="领证人"></el-input>
    </el-form-item>
    <el-form-item label="领证时间" prop="lzsj">
      <el-input v-model="dataForm.lzsj" placeholder="领证时间"></el-input>
    </el-form-item>
    <el-form-item label="共有方式" prop="gyfs">
      <el-input v-model="dataForm.gyfs" placeholder="共有方式"></el-input>
    </el-form-item>
    <el-form-item label="是否电子影像标识:1-是;0-否" prop="isdzyxyw">
      <el-input v-model="dataForm.isdzyxyw" placeholder="是否电子影像标识:1-是;0-否"></el-input>
    </el-form-item>
    <el-form-item label="是否存在登记人员信息集:1-是;0-否" prop="isdjryset">
      <el-input v-model="dataForm.isdjryset" placeholder="是否存在登记人员信息集:1-是;0-否"></el-input>
    </el-form-item>
    <el-form-item label="是否存在不动产信息集:1-是;0-否" prop="isbdcset">
      <el-input v-model="dataForm.isbdcset" placeholder="是否存在不动产信息集:1-是;0-否"></el-input>
    </el-form-item>
    <el-form-item label="是否存在询问笔录信息集:1-是;0-否" prop="isxwblset">
      <el-input v-model="dataForm.isxwblset" placeholder="是否存在询问笔录信息集:1-是;0-否"></el-input>
    </el-form-item>
    <el-form-item label="业务件号" prop="serviceno">
      <el-input v-model="dataForm.serviceno" placeholder="业务件号"></el-input>
    </el-form-item>
    <el-form-item label="受理号" prop="slh">
      <el-input v-model="dataForm.slh" placeholder="受理号"></el-input>
    </el-form-item>
    <el-form-item label="并案号" prop="bah">
      <el-input v-model="dataForm.bah" placeholder="并案号"></el-input>
    </el-form-item>
    <el-form-item label="状态" prop="status">
      <el-input v-model="dataForm.status" placeholder="状态"></el-input>
    </el-form-item>
    <el-form-item label="结果描述" prop="descinfo">
      <el-input v-model="dataForm.descinfo" placeholder="结果描述"></el-input>
    </el-form-item>
    <el-form-item label="备注" prop="remark">
      <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          seqno: 0,
          sendtime: '',
          recvtime: '',
          obankid: '',
          servicecode: '',
          ywlx: '',
          djsx: '',
          ishtbaset: '',
          region: '',
          bld: '',
          babsm: '',
          jtjbsm: '',
          djyy: '',
          fj: '',
          lzr: '',
          lzsj: '',
          gyfs: '',
          isdzyxyw: '',
          isdjryset: '',
          isbdcset: '',
          isxwblset: '',
          serviceno: '',
          slh: '',
          bah: '',
          status: '',
          descinfo: '',
          remark: ''
        },
        dataRule: {
          sendtime: [
            { required: true, message: '发送登记中心时间:YYYY-MM-DD HH:mm:ss不能为空', trigger: 'blur' }
          ],
          recvtime: [
            { required: true, message: '接收登记中心时间:YYYY-MM-DD HH:mm:ss不能为空', trigger: 'blur' }
          ],
          obankid: [
            { required: true, message: '发起网点号不能为空', trigger: 'blur' }
          ],
          servicecode: [
            { required: true, message: '业务标识码不能为空', trigger: 'blur' }
          ],
          ywlx: [
            { required: true, message: '业务类型不能为空', trigger: 'blur' }
          ],
          djsx: [
            { required: true, message: '登记事项不能为空', trigger: 'blur' }
          ],
          ishtbaset: [
            { required: true, message: '是否存在合同备案信息集:1-是;0-否不能为空', trigger: 'blur' }
          ],
          region: [
            { required: true, message: '区划代码不能为空', trigger: 'blur' }
          ],
          bld: [
            { required: true, message: '办理点不能为空', trigger: 'blur' }
          ],
          babsm: [
            { required: true, message: '并案标识码(合并编码)不能为空', trigger: 'blur' }
          ],
          jtjbsm: [
            { required: true, message: '集体件标识码不能为空', trigger: 'blur' }
          ],
          djyy: [
            { required: true, message: '登记原因不能为空', trigger: 'blur' }
          ],
          fj: [
            { required: true, message: '附记不能为空', trigger: 'blur' }
          ],
          lzr: [
            { required: true, message: '领证人不能为空', trigger: 'blur' }
          ],
          lzsj: [
            { required: true, message: '领证时间不能为空', trigger: 'blur' }
          ],
          gyfs: [
            { required: true, message: '共有方式不能为空', trigger: 'blur' }
          ],
          isdzyxyw: [
            { required: true, message: '是否电子影像标识:1-是;0-否不能为空', trigger: 'blur' }
          ],
          isdjryset: [
            { required: true, message: '是否存在登记人员信息集:1-是;0-否不能为空', trigger: 'blur' }
          ],
          isbdcset: [
            { required: true, message: '是否存在不动产信息集:1-是;0-否不能为空', trigger: 'blur' }
          ],
          isxwblset: [
            { required: true, message: '是否存在询问笔录信息集:1-是;0-否不能为空', trigger: 'blur' }
          ],
          serviceno: [
            { required: true, message: '业务件号不能为空', trigger: 'blur' }
          ],
          slh: [
            { required: true, message: '受理号不能为空', trigger: 'blur' }
          ],
          bah: [
            { required: true, message: '并案号不能为空', trigger: 'blur' }
          ],
          status: [
            { required: true, message: '状态不能为空', trigger: 'blur' }
          ],
          descinfo: [
            { required: true, message: '结果描述不能为空', trigger: 'blur' }
          ],
          remark: [
            { required: true, message: '备注不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.seqno = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.seqno) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcnoticeregist/info/${this.dataForm.seqno}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.sendtime = data.bdcNoticeregist.sendtime
                this.dataForm.recvtime = data.bdcNoticeregist.recvtime
                this.dataForm.obankid = data.bdcNoticeregist.obankid
                this.dataForm.servicecode = data.bdcNoticeregist.servicecode
                this.dataForm.ywlx = data.bdcNoticeregist.ywlx
                this.dataForm.djsx = data.bdcNoticeregist.djsx
                this.dataForm.ishtbaset = data.bdcNoticeregist.ishtbaset
                this.dataForm.region = data.bdcNoticeregist.region
                this.dataForm.bld = data.bdcNoticeregist.bld
                this.dataForm.babsm = data.bdcNoticeregist.babsm
                this.dataForm.jtjbsm = data.bdcNoticeregist.jtjbsm
                this.dataForm.djyy = data.bdcNoticeregist.djyy
                this.dataForm.fj = data.bdcNoticeregist.fj
                this.dataForm.lzr = data.bdcNoticeregist.lzr
                this.dataForm.lzsj = data.bdcNoticeregist.lzsj
                this.dataForm.gyfs = data.bdcNoticeregist.gyfs
                this.dataForm.isdzyxyw = data.bdcNoticeregist.isdzyxyw
                this.dataForm.isdjryset = data.bdcNoticeregist.isdjryset
                this.dataForm.isbdcset = data.bdcNoticeregist.isbdcset
                this.dataForm.isxwblset = data.bdcNoticeregist.isxwblset
                this.dataForm.serviceno = data.bdcNoticeregist.serviceno
                this.dataForm.slh = data.bdcNoticeregist.slh
                this.dataForm.bah = data.bdcNoticeregist.bah
                this.dataForm.status = data.bdcNoticeregist.status
                this.dataForm.descinfo = data.bdcNoticeregist.descinfo
                this.dataForm.remark = data.bdcNoticeregist.remark
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcnoticeregist/${!this.dataForm.seqno ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'seqno': this.dataForm.seqno || undefined,
                'sendtime': this.dataForm.sendtime,
                'recvtime': this.dataForm.recvtime,
                'obankid': this.dataForm.obankid,
                'servicecode': this.dataForm.servicecode,
                'ywlx': this.dataForm.ywlx,
                'djsx': this.dataForm.djsx,
                'ishtbaset': this.dataForm.ishtbaset,
                'region': this.dataForm.region,
                'bld': this.dataForm.bld,
                'babsm': this.dataForm.babsm,
                'jtjbsm': this.dataForm.jtjbsm,
                'djyy': this.dataForm.djyy,
                'fj': this.dataForm.fj,
                'lzr': this.dataForm.lzr,
                'lzsj': this.dataForm.lzsj,
                'gyfs': this.dataForm.gyfs,
                'isdzyxyw': this.dataForm.isdzyxyw,
                'isdjryset': this.dataForm.isdjryset,
                'isbdcset': this.dataForm.isbdcset,
                'isxwblset': this.dataForm.isxwblset,
                'serviceno': this.dataForm.serviceno,
                'slh': this.dataForm.slh,
                'bah': this.dataForm.bah,
                'status': this.dataForm.status,
                'descinfo': this.dataForm.descinfo,
                'remark': this.dataForm.remark
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
